
#include "iostream"
#include "vector"
#include "unordered_map"
#include "unordered_set"
#include "algorithm"
#include "string"
#include "list"
#include "string.h"
#include "math.h"

    bool cmp(std::string&a,std::string &b){
    std::string bpa=b+a;
    std::string apb=a+b;
    if(bpa<apb){
        return true;
    }else{
        return false;
    }
}
class OneLoop {
public:
    std::vector<std::string> strs;
    OneLoop(int a) {
        for(int i=0;i<a;i++){
            std::string s;
            std::cin>>s;
            strs.emplace_back(s);
        }
        std::sort(strs.begin(),strs.end(), cmp);
        for(auto&s:strs){
            std::cout<<s;
        }
        printf("\n");
    }
};

class Solution {
public:
    void run() {

        bool first = true;
        int a, b;
        std::string s;
        while (
                std::cin >> a
//                std::getline(std::cin,s)\

                ) {
            OneLoop loop(a);
        }
    }
};


int main() {


//    for(int i=3;i<100000000;i++){
//        if(is_chun_cu(i)){
//            printf("%d,",i);
//        }
//    }

//    bool cur_num= true;
    Solution().run();
    return 0;
}

